package base016

import "fmt"

func FunRun(){
	sum,avg := calc(3,5)
	fmt.Println("FunRun", sum,avg)
	fmt.Println("FunRun", addMore(6,1,2,3,4))

	a()
}

func a() {
	defer func() {
		fmt.Println("defer","1")
	}()
	defer func() {
		fmt.Println("defer","2")
	}()
	defer func() {
		fmt.Println("defer","3")
	}()
	fmt.Println("defer")
	return

	/*
	file := open(filename)
	defer file.Close()
	//文件操作
	*/
	/*
	mc.Lock()
	defer mc.Unlock()
	//其他操作
	*/
}


/**
	a,b 传入参数
	直接设置sum 和 avg是传出参数
 */
func calc(a, b int) (sum int, avg int) {
	sum = a + b
	avg = (a +b)/2
	return
}

func addMore(a int, arg... int) int {
	for _, v := range arg {
		a += v
	}
	return a
}

